﻿@model IEnumerable<ShareIt_MVC3.Models.Resource>

@{
    ViewBag.Title = "Index";
    var colorCheck = true;
}
<div class="post">
<h1>Alle Ressourcen</h1>

<p>
    @Html.ActionLink("Neue Ressource einstellen", "Create")
</p>
<table>
    <tr>
        
        <th>
            Titel
        </th>
        <th>
            Autor
        </th>
        <th>
            Kategorie
        </th>
        <th>
            Besitzer
        </th>
        <th>
            Ausleihbar
        </th>
        <th>Aktion</th>
    </tr>

@foreach (var item in Model) {
    <tr @((colorCheck == true) ? "class=colored-row" : "")>
 
        <td>
            @item.Title
        </td>
        <td>
            @item.Author
        </td>
        <td>
            @item.Category
        </td>
        <td>
            @item.Owner.Username
        </td>
        <td>
            @if (item.Active)
            {
                @:Ja
            }
            else
            {
                @:Nein
            }
        </td>
               <td>
            @Html.ActionLink("Anzeigen | Editieren", "Edit", new { id = item.ID })

        </td>
    </tr>
    
    if (colorCheck == false)
    {
        colorCheck = true;
    }
    else
    {
        colorCheck = false;
    }
}

</table>

</div>